package com.itheima.day14.Myvolatile.test2;

import java.util.concurrent.Callable;

// 小张
public class MyCallable1 implements Callable {

    @Override
    public Object call() throws Exception {
        synchronized (Money.obj) {
            // 先睡10毫秒
            try {
                Thread.sleep(10);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

            // 睡醒了挣钱
            for (int i = 0; i < 100; i++) {
                Money.money += 1;
            }
            // 挣完了去洗脚
            Money.money = Money.money - 2000;
            return null;
        }
    }
}
